package com.example.controller;

import com.example.pojo.Address;
import com.example.pojo.Result;
import com.example.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/address")
public class AddressController {

    @Autowired
    private AddressService addressService;
    @GetMapping
    public Result<Result.ResponseData<List<Address>>> getAddressTree() {
        List<Address> addressTree = addressService.getAddressTree();
        // 构建符合要求的响应结构
        Result.ResponseData<List<Address>> responseData = new Result.ResponseData<>();
        responseData.setCode(1000);
        responseData.setMsg("success");
        responseData.setData(addressTree);
        return Result.success(responseData);
    }
}